package cn.edu.sjtu.se.dslab.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.sjtu.se.dslab.component.data.EntityDiagram;
import cn.edu.sjtu.se.dslab.dao.IDiagramDao;
import cn.edu.sjtu.se.dslab.service.IDiagramService;

@Service("diagramService")
@Transactional
public class DiagramServiceImpl implements IDiagramService {

	@Resource(name = "diagramDao")
	private IDiagramDao diagramDao;

	@Override
	public boolean addDiagram(EntityDiagram diagram) {
		// TODO Auto-generated method stub
		diagramDao.save(diagram);
		return true;
	}

	@Override
	public EntityDiagram getDiagramById(long id) {
		// TODO Auto-generated method stub
		return diagramDao.queryById(id);
	}

	@Override
	public EntityDiagram getDiagramByUri(String uri) {
		// TODO Auto-generated method stub
		return diagramDao.queryByUri(uri);
	}

	@Override
	public boolean updateDiagram(EntityDiagram diagram) {
		// TODO Auto-generated method stub
		diagramDao.update(diagram);
		return true;
	}

}
